package dav.mobile.garuda.states;

import com.badlogic.gdx.Input;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;

import dav.mobile.garuda.components.Constants;
import dav.mobile.garuda.main.Main;

/*
 * State abstract class 
 */
public abstract class State {
	private Main 				m_Main;
	protected boolean 			m_Done;
	public 	SpriteBatch 		m_SpriteBatch;
	
	public final void Initialize(Main main) {
		this.m_Main = main;
		m_Done = false;
		m_SpriteBatch = new SpriteBatch(Constants.GAME_SPRITE_NUMBER);
	}
	
	public void Dispose() {
		m_SpriteBatch.dispose();
	}
	
	protected void SetState(State state) {
		m_Main.SetState(state);
	}
	
	public void Draw(TextureRegion region, int x, int y) {
		int width = region.getRegionWidth();
		
		if (width<0) width = -width;
		m_SpriteBatch.draw(region, x, y, width, -region.getRegionHeight());
	}
	
	public boolean IsDone() {
		return m_Done;
	}
	
	public abstract void Update();
	public abstract void Render();
	
	public void Tick(Input input) {
		
	}
}
